<template>
	<el-dialog :title="titleMap[mode]" v-model="visible" width="90%" destroy-on-close @closed="$emit('closed')" :align-center="true">
        <el-form :model="form" :rules="rules" ref="dialogForm" :disabled="mode == 'show'" label-width="110px" label-position="top" style="height:450px;overflow:auto">
            <el-form-item label="物料信息" prop="detail">
                <sc-form-table ref="table" v-model="form.detail" placeholder="暂无数据" hideAdd hideDelete>
                    <el-table-column prop="material_name" label="物料名称" align="center"></el-table-column>
                    <el-table-column prop="referred_as" label="供应商" align="center"></el-table-column>
                    <el-table-column prop="color_number" label="物料色号" align="center"></el-table-column>
                    <el-table-column prop="colour" label="物料颜色" align="center"></el-table-column>
                    <el-table-column prop="batch_no" label="缸号" align="center"></el-table-column>
                    <el-table-column prop="num" label="需发数量" align="center"></el-table-column>
                    <el-table-column prop="income_num" label="实际发毛" align="center"></el-table-column>
                </sc-form-table>
            </el-form-item>
        </el-form>
	</el-dialog>
</template>
<script>
	export default {
		emits: ['success', 'closed'],
		data() {
			return {
				mode: "add",
				titleMap: {
					add: '添加客户',
					edit: '发毛',
					show: '领毛明细'
				},
				visible: false,
				isSaveing: false,
                form:{
                    detail:[]
                }
			}
		},
		mounted() {
		},
		methods: {
			//显示
			open(mode='add'){
				this.mode = mode;
				this.visible = true;
				return this
			},
			//表单注入数据
			setData(data){
                var info = data.detail
                let array = []
                info.map(item=>{
                    array.push({
                        material_name:item.material_name,
                        referred_as:item.materialSpec.referred_as,
                        color_number:item.materialSpec.color_number,
                        colour:item.materialSpec.colour,
                        batch_no:item.batch_number,
                        income_num:item.income_num,
                        num:item.num,
                    })
                })
                this.form.detail = array
			},
		}
	}
</script>

<style lang="scss">
.el-form-item--default{
    align-items: center;
}
</style>
